package com.jiatui.sharding;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jiatui.sharding.dao.User;
import com.jiatui.sharding.dao.UserMapper;

@RestController
public class UserController {

	@Autowired
	private UserMapper userMapper;

	private int id = 3;

	private int age = 30;

	@GetMapping("/user/get")
	public String getUser() {
		return userMapper.getUser();
	}

	@GetMapping("/user/save")
	public String saveUser() {
		User user = new User();
		user.setId(id++);
		user.setName("name" + id);
		user.setAge(age++);
		userMapper.insertUser(user);
		return "ok";
	}

}
